<fieldset class="info-basic">
	<legend><?php echo t('PART_BASIC','profile') ?></legend>
	<table>
		<tr>
			<td style="vertical-align: top">
				<table class="form">
					<tr>
						<td class="label" rowspan="2"><?php echo $form->labelEx($model, 'full_name'); ?></td>
						<td rowspan="2" class="input" style="width: 330px;"><?php            
				echo $form->textField($model, 'full_name', array('class' => 'fullname'));
				echo $form->error($model, 'full_name');
				?></td>
						<td class="label"><?php echo $form->labelEx($model, 'sex'); ?></td>
						<td class="input" style="width: 170px;"><?php
				echo $form->dropDownList($model, 'sex', CHtml::listData(LGHelpers::getSexListData(), 'id', 'name'), array('style' => 'width:150px', 'empty' => t('MSG_FIRST_ITEM_SEX', 'messages')));
				echo $form->error($model, 'sex');
				?></td>
					</tr>
					<tr>
						<td class="label"><?php echo $form->labelEx($model, 'phone_number'); ?></td>
						<td class="input"><?php            
				echo $form->textField($model, 'phone_number', array('style' => 'width:142px'));
				echo $form->error($model, 'phone_number');
				?></td>
					</tr>
					<tr>
						<td class="label"><?php echo $form->labelEx($model, 'birth_date'); ?></td>
						<td class="input"><?php            
				echo $form->textField($model, 'birth_date', array('style' => 'width:275px', 'class' => 'datepicker', 'readonly'=>'true'));
				echo $form->error($model, 'birth_date');
				?></td>
						<td class="label"><?php echo $form->labelEx($model, 'birth_place'); ?></td>
						<td class="input"><?php
				echo $form->dropDownList($model, 'birth_place', Province::model()->getChtmlLanguage(), array('style' => 'width:150px', 'empty' => t('MSG_FIRST_ITEM_BIRTH_PLACE', 'messages')));
				echo $form->error($model, 'birth_place');
				?></td>
					</tr>
					<tr>
						<td class="label"><?php echo $form->labelEx($model, 'address'); ?></td>
						<td class="input" colspan="3" style="width: 64px"><?php            
				echo $form->textField($model, 'address', array('style' => 'width:628px'));
				echo $form->error($model, 'address');
				?></td>
					</tr>
				</table>
			</td>
			<td width="30px"></td>
			<td style="vertical-align: top; width: 100px">
				<table>
					<tr>
						<td colspan="2"><?php                                     
				if($model->photo_url == null || $model->photo_url == ""){
					echo CHtml::image("media/profile/no_image.jpg","",
					array("id" => "thumbnail","width"=>"120px" ,"height"=>"130px", "style" => "border:1px solid #ddd"));
				}else{
					$imgSrc = file_exists(PROFILE_FOLDER . $model->photo_url)? SITE_URL. "media/profile/" . $model->photo_url : SITE_URL. "media/profile/no_image.jpg";
					echo CHtml::image($imgSrc,"",
					array("id" => "thumbnail","width"=>"120px" ,"height"=>"130px", "style" => "border:1px solid #ddd"));
				}
				?></td>
					</tr>
					<tr class="hideonview">
						<td><a href="#" id="changeImage"><?php echo t('LNK_UPDATE_PICTURE','profile') ?></a>
						</td>
						<td><a href="#" id="deleteImage"><?php echo t('LNK_DELETE_PICTURE','profile') ?></a>
						</td>
						<td><input type="file" name="Profile[picture]" id="selectImage"
							style="visibility: hidden" onchange="PreviewImage()" /></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</fieldset>
<script type="text/javascript">
	$('#changeImage').click(function(){
            $('#selectImage').trigger('click');
            return false;
        });
        function PreviewImage() {
            var oFReader = new FileReader();
            oFReader.readAsDataURL(document.getElementById("selectImage").files[0]);

            oFReader.onload = function (oFREvent) {
                document.getElementById("thumbnail").src = oFREvent.target.result;
            };
        };
</script>
<?php
if ($model != null && $model->id != null && $model->photo_url != null) {
	Yii::app ()->clientScript->registerScript ( 'deleteImage', '
        $("#deleteImage").click(function(e){            
            var _index = ' . $model->id . ';
            e.preventDefault();                
            var _url = "' . Yii::app ()->controller->createUrl ( "removePictureByAjax", array (
			"load_for" => $this->action->id 
	) ) . '&index="+_index;                 
            $.ajax({                
                url: _url,
                success:function(){
            document.getElementById("thumbnail").src = "media/profile/no_image.jpg";
            document.getElementById("selectImage").value="";
                }
            });
        });
', CClientScript::POS_END );
} else {
	Yii::app ()->clientScript->registerScript ( 'deleteImage', '
        $("#deleteImage").click(function(e){                                                    
            document.getElementById("thumbnail").src = "media/profile/no_image.jpg";
            document.getElementById("selectImage").value="";  
            e.preventDefault(); 
        });
    ', CClientScript::POS_END );
}
?>